package bbsimon.first.reg;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import bbsimon.first.model.reg.RegModel;

public class RegServlet extends HttpServlet {
	public void doPost(HttpServletRequest req, HttpServletResponse res)
		throws IOException, ServletException {

			res.setContentType("text/html");
			PrintWriter out = res.getWriter();
			out.println("<html><head><title>Register</title><body>");
			String email = req.getParameter("email");
			String pw = req.getParameter("password");
			RegModel rm = new RegModel();
			try{
				rm.reg(email, pw);
			}
			catch(Exception e) {
				out.println("<h1>Registeration fails</h1><p>" + e.getMessage()
						+ "</p><br><a href=\"./\">Back</a>");
				return;
			}
			out.println("<h1>Registeration successes</h1><p><b>"
					+ email + "</b> has signed in our web app</p>"
					+ "<br><a href=\"./\">Back</a>");
		}

}

